测试链接：https://leetcode.cn/problems/jJ0w9p/description/
class Solution {
public:
    int mySqrt(int x) {
        int l = 1;
        int r = x;

        int ans = 0;
        while(l <= r)
        {

            long long mid = l + (r - l + 1)/2;
            if((long long)mid * mid <= x)
            {
                ans = mid;
                l = mid + 1;
            }
            else
            {
                r = mid - 1;
            }
        }
        return ans;
    }
};